/**
 *
 */
package com.effectiv.gooruda.interceptor;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lombok.extern.slf4j.Slf4j;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @author Dhrubo
 *
 */
@Slf4j
public class TabHighlightingInterceptor extends HandlerInterceptorAdapter{

	private Map<String,String> requestMap;



	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {


		log.debug("Request URI - {}", request.getRequestURI());

		String uri = request.getRequestURI();

		if(requestMap.containsKey(uri)){

			log.debug("Found key = {}", requestMap.get(uri));

			modelAndView.addObject("nav", requestMap.get(uri));
		}


	}

	public void init(){
		requestMap = new HashMap<String,String>();
		requestMap.put("/console/newapplication", "apps");
		requestMap.put("/console/listapplications", "apps");
		requestMap.put("/console/editapplication", "apps");

		requestMap.put("/console/docs", "docs");

		requestMap.put("/console/newprojectuser", "project");
		requestMap.put("/console/updatemanager", "project");

		requestMap.put("/console/listusecases", "uc");
		requestMap.put("/console/viewusecase", "uc");
		requestMap.put("/console/editusecase", "uc");

		requestMap.put("/console/home", "home");

	}
}
